package memento;

/**
 * @author wcj
 * @Date 2021/7/1 18:18
 * @Version 1.0
 */
public class GameRole {

    private Integer hp;

    private Integer mp;

    private Integer def;

    public void initRole() {
        this.hp = 100;
        this.mp = 100;
        this.def = 100;
    }

    public void fight() {
        this.hp = 0;
        this.mp = 0;
        this.def = 0;
    }

    public void show() {
        System.out.println("生命值:" + this.hp + "\n" + "魔法值:" + this.mp + "\n" + "防御力:" + this.def);
    }

    public Memento saveGameRole() {
        return new Memento(this.hp, this.mp, this.def);
    }

    public void recoveryGameRole(Memento memento) {
        this.hp = memento.getHp();
        this.mp = memento.getMp();
        this.def = memento.getDef();
    }
}
